import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class day_06_IO_Test_07 {
    public static void main(String[] args) throws IOException {
        // 统计文件运行次数
        BufferedReader bufferedReader = new BufferedReader(new FileReader("count.txt"));
        String line = bufferedReader.readLine();
        bufferedReader.close();

        int count = Integer.parseInt(line);
        count++;

        if (count <= 3) {
            System.out.println("欢迎使用本软件，第" + count + "次免费试用！");
        } else {
            System.out.println("本软件只能免费试用3次，欢迎注册会员后使用！");
        }

        // 将count写入文件
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("count.txt"));
        bufferedWriter.write(count + "");
        bufferedWriter.close();
    }
}
